<!doctype html>
<html>
<head>
<script src="/blue/js/jquery.js"></script>
<link href="/blue/css/css.css" rel="stylesheet" type="text/css">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<meta name="format-detection" content="telephone=no" />
<meta charset="utf-8">
<title>蓝色家政添加服务地址</title>
<style>
/*地址输入框*/
.column_box input{ line-height:46px; color:#191919; font-size:14px; float:left; margin-left:12px;}
</style>
</head>

<body style="background-color: #f9f9f9;">
<!--header顶部标题-->
<div class="header">添加服务地址
	<div class="header_left" onclick="window.history.go(-1)"><img src="/blue/images/return.png"></div>
</div>
<!--column搜索小区-->
<div class="column_box" onclick="document.location='address_search';">
	<div class="border_top"></div>
	<div class="column_img"><img src="/blue/images/adrress.png"></div>
    @if($cha == null)<p id="xiao">搜索小区</p>@else<p id="xiao" name="xiao">{{$cha->community}}<p><p style='display: none' id="cid">{{$cha->id}}</p>@endif
    <div class="next"><img src="/blue/images/arrow.png"></div>
    <div class="border_bottom"></div>
</div>
<!--column详细地址-->
<div class="column_box">
	<div class="column_img"><img src="/blue/images/adrress_2.png"></div>
    <input placeholder="详细地址，如xx号楼xx单元xx室" name="qu" id="qu"></input>
    <div class="border_bottom"></div>
</div>
<!--acreage面积-->

<!--column联系人-->
<div class="column_box">
	<div class="column_img"><img src="/blue/images/people.png"></div>
    <input placeholder="联系人"  id="lian" name="lian"></input>
    <div class="border_bottom"></div>
</div>
<!--column电话-->
<div class="column_box">
	<div class="column_img"><img src="/blue/images/phone.png"></div>
    <input placeholder="联系电话" type="number" id="tel" name="tel"></input>
    <div class="border_bottom"></div>
</div>
<!--confirm确认添加-->
	<div class="confirm" id="jia">确认添加</div>
<script>
var i=0;
var x=0;
$(".area_box").click(function(){//点击下拉列表

	if(i==0){$(".area_box").animate({height:'187px'});i=1}else{$(".area_box").animate({height:'32px'}); i=0}//显示隐藏选项
	})
$(".box").click(function(){//点击选项：切换背景颜色
	$(this).css("background-color","#CCCCCC").siblings().css("background-color","#fff");
	$(".chenge").html($(this).html());//点击选项：替换文本
	})

    $("#jia").click(function () {
        var tel = $("#tel").val();
        var lian = $("#lian").val();
        var qu = $("#qu").val();
        var xiao = $("#xiao").text();
        var cid = $("#cid").text();

        if(lian == ''){
            alert('请填写联系人名字');
        }else if(qu == ''){
            alert('请填写详细地址');
        }else if(xiao == '搜索小区'){
            alert('请填地址');
        }else if(tel == ''){
            alert('请填写联系人的电话');
        }else if(!(/^1\d{10}$/.test(tel))){
            alert('您手机号填写有误');
        }else{
            $.get("address",{'community':xiao,'tel':tel,'lian':lian,'qu':qu,'cid':cid},function (res) {
                if(res==0){
                    location.href ="address?ii=ri";
                }else{
                    alert('抱歉添加失败');
                }
            });
        }
    });
</script>
</body>
</html>
